//
//  WSReceiveSuccessController.m
//  CharonTVProject
//
//  Created by karong on 2023/7/31.
//

#import "WSReceiveSuccessController.h"
#import "WSTask.h"

@interface WSReceiveSuccessController ()

@property (weak, nonatomic) IBOutlet UILabel *titleLabel;
@property (weak, nonatomic) IBOutlet UILabel *coinsLabel;
@property (weak, nonatomic) IBOutlet UIImageView *animationView;

@end

@implementation WSReceiveSuccessController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.coinsLabel.text = WSSF(@"+%ldCoins", (long)self.task.charonTV_coins);
    [self layoutTitleLabel];
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.2 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self addAnimation];
    });
}

- (void)layoutTitleLabel {
    UIColor * textColor = [UIColor colorFromHexRGB:@"F23735"];
    CGFloat font = 20;
    if (self.task.charonTV_task_identify == 0) {
        textColor = UIColor.font_black_333333;
        font = 14;
        self.titleLabel.text = APPLocalized(@"簽到成功");
    }
    if (self.task.charonTV_task_identify == -1) {
        self.titleLabel.text = APPLocalized(@"已完整觀看完廣告，再送您");
    }
    self.coinsLabel.textColor = textColor;
    self.coinsLabel.font = [UIFont systemFontOfSize:font];
}

- (void)addAnimation {
    CABasicAnimation *rotationAnimation;
    rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
    rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI];
    rotationAnimation.duration = 2;
    rotationAnimation.cumulative = YES;
    rotationAnimation.repeatCount = 10000;
    [self.animationView.layer addAnimation:rotationAnimation forKey:@"rotationAnimation"];
}

- (IBAction)closeAction:(id)sender {
    [self dismiss];
}
@end
